// 防抖：控制触发次数
let antiShakeTime = 1000;
function antiShake(func, time = antiShakeTime) {
    let timeOutFun = null;
    return () => {
        if (timeOutFun) {
            clearTimeout(timeOutFun);
            console.log('清除之前的');
        }
        timeOutFun = setTimeout(func, time);
    };
}

// 节流：控制触发频率
let throttleTime = 200;
function throttle(func, time = throttleTime) {
    let timeOutFun = null;
    return () => {
        if (!timeOutFun) {
            timeOutFun = setTimeout(() => {
                func.apply(this);
                timeOutFun = null;
            }, time);
        }
    };
}
export { antiShake, throttle };
